{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 57,
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "import pandas as pd\n",
    "import matplotlib.pyplot as plt\n",
    "import matplotlib.dates as md\n",
    "%matplotlib inline\n",
    "import warnings\n",
    "warnings.filterwarnings(\"ignore\")\n",
    "plt.rcParams[\"font.sans-serif\"] = [\"SimHei\"]\n",
    "plt.rcParams[\"axes.unicode_minus\"] = False\n",
    "pd.options.display.max_rows = 20"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 85,
   "metadata": {},
   "outputs": [],
   "source": [
    "def get_data(file_path, func=open) -> pd.DataFrame:\n",
    "    \"\"\"\n",
    "    从文件中 IO 获取数据\n",
    "    :param file_path:\n",
    "    :param func:\n",
    "    :return:\n",
    "    \"\"\"\n",
    "    with func(file_path) as f:\n",
    "        temp_data = pd.read_csv(f)\n",
    "    return temp_data"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 86,
   "metadata": {},
   "outputs": [],
   "source": [
    "data = get_data(r\"C:\\Users\\新田草\\Desktop\\正仁量化\\data\\bar_data.csv\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 87,
   "metadata": {},
   "outputs": [],
   "source": [
    "data = data.iloc[:, 1:]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 88,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>contract</th>\n",
       "      <th>time</th>\n",
       "      <th>Timestamp</th>\n",
       "      <th>open</th>\n",
       "      <th>high</th>\n",
       "      <th>low</th>\n",
       "      <th>close</th>\n",
       "      <th>volume</th>\n",
       "      <th>bid_side_vol</th>\n",
       "      <th>ask_side_vol</th>\n",
       "      <th>bid_ask_ratio</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>CY1805</td>\n",
       "      <td>2018-01-02 10:06:06+08:00</td>\n",
       "      <td>1514858766</td>\n",
       "      <td>23205</td>\n",
       "      <td>23215.0</td>\n",
       "      <td>23070</td>\n",
       "      <td>23070</td>\n",
       "      <td>15</td>\n",
       "      <td>2</td>\n",
       "      <td>9</td>\n",
       "      <td>-0.636</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>CY1805</td>\n",
       "      <td>2018-01-03 14:24:21+08:00</td>\n",
       "      <td>1514960661</td>\n",
       "      <td>23070</td>\n",
       "      <td>23200.0</td>\n",
       "      <td>23060</td>\n",
       "      <td>23200</td>\n",
       "      <td>13</td>\n",
       "      <td>6</td>\n",
       "      <td>5</td>\n",
       "      <td>0.091</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>CY1805</td>\n",
       "      <td>2018-01-03 14:43:18+08:00</td>\n",
       "      <td>1514961798</td>\n",
       "      <td>23200</td>\n",
       "      <td>23070.0</td>\n",
       "      <td>23070</td>\n",
       "      <td>23070</td>\n",
       "      <td>2</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>-1.000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>CY1805</td>\n",
       "      <td>2018-01-03 14:54:26+08:00</td>\n",
       "      <td>1514962466</td>\n",
       "      <td>23070</td>\n",
       "      <td>23130.0</td>\n",
       "      <td>22940</td>\n",
       "      <td>22940</td>\n",
       "      <td>25</td>\n",
       "      <td>6</td>\n",
       "      <td>14</td>\n",
       "      <td>-0.400</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>CY1805</td>\n",
       "      <td>2018-01-03 21:06:26+08:00</td>\n",
       "      <td>1514984786</td>\n",
       "      <td>22940</td>\n",
       "      <td>23055.0</td>\n",
       "      <td>22920</td>\n",
       "      <td>23055</td>\n",
       "      <td>13</td>\n",
       "      <td>3</td>\n",
       "      <td>5</td>\n",
       "      <td>-0.250</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "  contract                       time   Timestamp   open     high    low  \\\n",
       "0   CY1805  2018-01-02 10:06:06+08:00  1514858766  23205  23215.0  23070   \n",
       "1   CY1805  2018-01-03 14:24:21+08:00  1514960661  23070  23200.0  23060   \n",
       "2   CY1805  2018-01-03 14:43:18+08:00  1514961798  23200  23070.0  23070   \n",
       "3   CY1805  2018-01-03 14:54:26+08:00  1514962466  23070  23130.0  22940   \n",
       "4   CY1805  2018-01-03 21:06:26+08:00  1514984786  22940  23055.0  22920   \n",
       "\n",
       "   close  volume  bid_side_vol  ask_side_vol  bid_ask_ratio  \n",
       "0  23070      15             2             9         -0.636  \n",
       "1  23200      13             6             5          0.091  \n",
       "2  23070       2             0             1         -1.000  \n",
       "3  22940      25             6            14         -0.400  \n",
       "4  23055      13             3             5         -0.250  "
      ]
     },
     "execution_count": 88,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 89,
   "metadata": {},
   "outputs": [],
   "source": [
    "length = 100\n",
    "dates, open_price, high_price, low_price, close_price, volumes = data[\"time\"][:length], data[\"open\"][:length], data[\"high\"][:length], data[\"low\"][:length], data[\"close\"][:length], data[\"volume\"][:length]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 56,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAt8AAAHWCAYAAACv7eWRAAAABHNC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kyQHDhzIf/7nfwpvgGMQ3wCDzAsvvJAk+fjHP949Vl1dnRUrVmTcuHG57LLLcsEFF+Tv//7v84Mf/CB//Md/nDPO+P//3f/FX/xFj3j+ZZdffnl27tyZlpaWHDhwII8++mieeuqpfPazn02S7Nq1K+PGjeuxT21tbV566aUkyfPPP58k+cpXvpJLL70006ZNy0MPPXTSzh1gsHPbCcAgs3v37iTJqFGjeoz/zu/8Tvf3N9xwQ26//fYMHz681wOYvxzi7zRhwoR86UtfytKlS7N06dIkya233ppLLrkkSfL2229n5MiRPfb5wAc+kP/5n/9Jkvz85z/PWWedlSlTpuSWW27J008/neXLl+e8887rdX85wOlIfAMMMocOHUpy/IieNm1avv71r+dzn/tchg8f3u9j/8d//Efuv//+TJ8+PZdffnn+7d/+Lffdd18+8pGPZNq0aTn77LPz1ltv9djnrLPO6h6bOnVqrrjiiu6r8pdffnna29vz8MMPi2+AuO0EYND5v5g+ePBg99jhw4cza9asbNq0KcnRID733HO7P4Gkv/7u7/4un/rUp3LnnXdm6tSpWbx4cW644Yb8zd/8TZLkvPPOy6uvvtpjn7179+aDH/xgkmT06NE9bodJkvr6+u5bZQBOd+IbYJD52Mc+liR5+eWXu8f27t2brVu35vDhw+/r2C+99FI++tGP9hgbN25cXnnllSTJhRdemGeffTZvv/129+937NiR888/P8nRjxlsb2/vsf/evXtTVVX1vtYFMFSIb4BB5uKLL85ZZ52Vf/mXf+ke27JlS6qqqvIbv/Eb7+vYH/rQh7J9+/YeY0888UR3XF9++eXp6urKmjVrkhz9dJN169blU5/6VJKjL+757ne/273v4cOH88gjj+QTn/jE+1oXwFDhnm+AQWbUqFGZM2dOVqxYkREjRqSmpibLli3L1VdfnTFjxryvY0+aNClf/vKXM3/+/IwbNy47duzIE088kQULFiRJzj777Nx000355je/mS1btuT555/Pvn37Mnv27CTJ9OnTc+utt2bEiBH56Ec/mn/8x3/M888/nxUrVrzv8wYYCsQ3wCB0yy235Oyzz05TU1P279+fq6++us9XxZ+oz372s3nrr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CQ+vr6bN68OW1tbamvr8+ZZ56Zu+++OyNGjOjeb/PmzZk6dWqS5OKLL87Pf/7zPscAAGCw6PdHDX74wx9OS0tLr48aPOOM/vX7tm3bsnfv3tTX16erqysbNmzIqFGjMmzYsHzwgx/stf3BgwczZsyYJEl1dXVef/31PsfeqaWlJQ8//HCS5I033ujv6QEAQMWd0EcNnnHGGamvr8/UqVNTX1/f7/Du7OzMsmXLsnTp0iRJVVVVlixZkgsuuCCtra197nPOOefkrbfeSpIcOHAgR44c6XPsnWbMmJHm5uY0Nzfn/PPPP5HTAwCAijqh+H4vDh06lIULF2bBggWpq6vLqlWrsm7duiRHH8YcOXJkn/uNHz8+W7ZsSZI8//zz+chHPtLnGAAADBb9vu3kvVq7dm22b9+epqamNDU1pbGxMWvWrMmaNWsybty47vvB3+m6667LF7/4xWzZsiUvvvhiJk6cmDFjxvQaAwCAweK48V1fX58nnngi5557bn7zN3+zx8cMJklXV1eqqqrys5/97JjHaGxsTGNjY4+xadOm9bntgw8+2P19XV1dVq5cmS1btmT+/Pk588wz+xwDAIDB4rjx/c///M8599xzkyQbNmwosqBfNmbMmF6h3tcYAAAMBseN77q6uj6/BwAATlzFH7gEAACOEt8AAFBIv+N79erV6ejoqORaAAA4lbS2Hv3ipOl3fDc3N2fHjh2VXAsAAAxp/Y7vefPmZeXKlV7ZDgAA71G/X7Kzc+fOnHHGGfnc5z6X6667Luecc073726++eaKLA4AAIaSfsf3K6+8krFjx2bs2LHZvXt39/g7X7wDAAD07V3ju6OjI08//XQuvvjifPKTn8zYsWNLrAs4ldXWJpV+ALumJmlv7z318tp07K/c3DUjatK+qPe8AHAyHPee78cffzyf//zn88ADD+T73/9+pk+fnrVr15ZaG3CqKvHJR8eYo5LhXeL4AJzejnvl+5577smXv/zlfOELX0iSbNq0KYsWLcof/MEfFFkcAAAMJce98v3v//7vufLKK7t/bmhoyNtvv51XX3214gsDAICh5rjxfeTIkR6fapIkH/jAB3L48OGKLgoAAIai49520tXVlauuuqrH2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NhAL6CSXnzxxUyYMGGglwEAwBD3X//1X/3arqqtra2rwmsBAADithMAAChGfAMAQCHiGwAAChHfAABQiPgGAIBCxDcAABQivgEAoBDxDQAAhYhvAAAo5P8BB7ND2ZCvJp4AAAAASUVORK5CYII=\n",
      "text/plain": [
       "<Figure size 864x576 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "# 2.设置绘图窗口\n",
    "plt.figure(figsize = (12, 8), facecolor=\"lightgray\")\n",
    "plt.title(\"CY1805\", fontsize=16)\n",
    "plt.xlabel(\"Data\", fontsize=14)\n",
    "plt.ylabel(\"Price\", fontsize=14)\n",
    "\n",
    "contract_multiplier = 5\n",
    "up = high_price.max() + contract_multiplier*10\n",
    "bottom = low_price.min() - contract_multiplier*10\n",
    "\n",
    "plt.ylim([bottom, up])\n",
    "\n",
    "# 3.x坐标（时间轴）轴修改\n",
    "ax = plt.gca()\n",
    "# y 轴不可见\n",
    "# ax.axes.get_yaxis().set_visible(False)\n",
    "# x 轴不可见\n",
    "ax.axes.get_xaxis().set_visible(False)\n",
    "\n",
    "# 4.判断收盘价与开盘价 确定蜡烛颜色\n",
    "colors_bool = close_price >= open_price\n",
    "colors = np.zeros(colors_bool.size, dtype=\"U5\")\n",
    "colors[:] = \"green\"\n",
    "colors[colors_bool] = \"red\"\n",
    "\n",
    "# 5.确定蜡烛边框颜色\n",
    "edge_colors = np.zeros(colors_bool.size, dtype=\"U1\")\n",
    "edge_colors[:] = \"g\"\n",
    "edge_colors[colors_bool] = \"r\"\n",
    "\n",
    "# 6.绘制蜡烛\n",
    "plt.bar(dates, (close_price - open_price), 0.8, bottom=open_price, color=colors,\n",
    "       edgecolor=edge_colors, zorder=3)\n",
    "\n",
    "# 7.绘制蜡烛直线(最高价与最低价)\n",
    "plt.vlines(dates, low_price, high_price, color=edge_colors)\n",
    "\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 90,
   "metadata": {},
   "outputs": [],
   "source": [
    "prices = [[o, h, l, c] for o, h, l, c in zip(open_price, high_price, low_price, close_price)]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 91,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[[23205, 23215.0, 23070, 23070],\n",
       " [23070, 23200.0, 23060, 23200],\n",
       " [23200, 23070.0, 23070, 23070],\n",
       " [23070, 23130.0, 22940, 22940],\n",
       " [22940, 23055.0, 22920, 23055],\n",
       " [23055, 23115.0, 22930, 22930],\n",
       " [22930, 23085.0, 22970, 23085],\n",
       " [23085, 23065.0, 22915, 22915],\n",
       " [22915, 23030.0, 22990, 23030],\n",
       " [23030, 23165.0, 23000, 23165],\n",
       " [23165, 23155.0, 23030, 23030],\n",
       " [23030, 23190.0, 22955, 23190],\n",
       " [23190, 23120.0, 22970, 22970],\n",
       " [22970, 23120.0, 23120, 23120],\n",
       " [23120, 23260.0, 23070, 23260],\n",
       " [23260, 23230.0, 23120, 23120],\n",
       " [23120, 23255.0, 23065, 23255],\n",
       " [23255, 23260.0, 23130, 23130],\n",
       " [23130, 23280.0, 23090, 23280],\n",
       " [23280, 23230.0, 23130, 23130],\n",
       " [23130, 23300.0, 23160, 23300],\n",
       " [23300, 23230.0, 23100, 23100],\n",
       " [23100, 23255.0, 23155, 23255],\n",
       " [23255, 23135.0, 23135, 23135],\n",
       " [23135, 23300.0, 23030, 23300],\n",
       " [23300, 23325.0, 23135, 23135],\n",
       " [23135, 23270.0, 23115, 23270],\n",
       " [23270, 23440.0, 23200, 23440],\n",
       " [23440, 23350.0, 23285, 23285],\n",
       " [23285, 23410.0, 23170, 23410],\n",
       " [23410, 23225.0, 23225, 23225],\n",
       " [23225, 23380.0, 23120, 23380],\n",
       " [23380, 23250.0, 23250, 23250],\n",
       " [23250, 23370.0, 23310, 23370],\n",
       " [23370, 23350.0, 23250, 23250],\n",
       " [23250, 23425.0, 23155, 23425],\n",
       " [23425, 23300.0, 23300, 23300],\n",
       " [23300, 23445.0, 23225, 23445],\n",
       " [23445, 23275.0, 23275, 23275],\n",
       " [23275, 23385.0, 23140, 23140],\n",
       " [23140, 23270.0, 23270, 23270],\n",
       " [23270, 23430.0, 23270, 23430],\n",
       " [23430, 23290.0, 23290, 23290],\n",
       " [23290, 23465.0, 23225, 23465],\n",
       " [23465, 23365.0, 23305, 23305],\n",
       " [23305, 23425.0, 23285, 23425],\n",
       " [23425, 23445.0, 23290, 23290],\n",
       " [23290, 23420.0, 23330, 23420],\n",
       " [23420, 23275.0, 23275, 23275],\n",
       " [23275, 23500.0, 23235, 23500],\n",
       " [23500, 23410.0, 23280, 23280],\n",
       " [23280, 23410.0, 23410, 23410],\n",
       " [23410, 23530.0, 23530, 23530],\n",
       " [23530, 23420.0, 23280, 23280],\n",
       " [23280, 23430.0, 23430, 23430],\n",
       " [23430, 23555.0, 23410, 23555],\n",
       " [23555, 23590.0, 23390, 23390],\n",
       " [23390, 23550.0, 23385, 23550],\n",
       " [23550, 23620.0, 23360, 23360],\n",
       " [23360, 23535.0, 23430, 23535],\n",
       " [23535, 23255.0, 23255, 23255],\n",
       " [23255, 23690.0, 23690, 23690],\n",
       " [23690, 23520.0, 23520, 23520],\n",
       " [23520, 23350.0, 23350, 23350],\n",
       " [23350, 23785.0, 23450, 23785],\n",
       " [23785, 23455.0, 23455, 23455],\n",
       " [23455, 22960.0, 22960, 22960],\n",
       " [22960, 23400.0, 23400, 23400],\n",
       " [23400, 23740.0, 23740, 23740],\n",
       " [23740, 23520.0, 23520, 23520],\n",
       " [23520, 23435.0, 23375, 23375],\n",
       " [23375, 23535.0, 23400, 23535],\n",
       " [23535, 23705.0, 23515, 23705],\n",
       " [23705, 23630.0, 23550, 23550],\n",
       " [23550, 23635.0, 23430, 23430],\n",
       " [23430, 23595.0, 23595, 23595],\n",
       " [23595, 23485.0, 23455, 23455],\n",
       " [23455, 23585.0, 23365, 23585],\n",
       " [23585, 23410.0, 23410, 23410],\n",
       " [23410, 23580.0, 23365, 23580],\n",
       " [23580, 23525.0, 23220, 23220],\n",
       " [23220, 23430.0, 23430, 23430],\n",
       " [23430, 23590.0, 23590, 23590],\n",
       " [23590, 23525.0, 23450, 23450],\n",
       " [23450, 23570.0, 23570, 23570],\n",
       " [23570, 23535.0, 23215, 23215],\n",
       " [23215, 23445.0, 23445, 23445],\n",
       " [23445, 23560.0, 23120, 23120],\n",
       " [23120, 23440.0, 23440, 23440],\n",
       " [23440, 23550.0, 23320, 23320],\n",
       " [23320, 23465.0, 23275, 23465],\n",
       " [23465, 23655.0, 23655, 23655],\n",
       " [23655, 23465.0, 23465, 23465],\n",
       " [23465, 23345.0, 23345, 23345],\n",
       " [23345, 23455.0, 23225, 23225],\n",
       " [23225, 23310.0, 23060, 23060],\n",
       " [23060, 23175.0, 22575, 22575],\n",
       " [22575, 23360.0, 23360, 23360],\n",
       " [23360, 23720.0, 23720, 23720],\n",
       " [23720, 23750.0, 23355, 23355]]"
      ]
     },
     "execution_count": 91,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "prices"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 92,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "100"
      ]
     },
     "execution_count": 92,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "len(dates)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 93,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['2018-01-02 10:06:06+08:00',\n",
       " '2018-01-03 14:24:21+08:00',\n",
       " '2018-01-03 14:43:18+08:00',\n",
       " '2018-01-03 14:54:26+08:00',\n",
       " '2018-01-03 21:06:26+08:00',\n",
       " '2018-01-04 14:59:30+08:00',\n",
       " '2018-01-05 11:25:56+08:00',\n",
       " '2018-01-05 14:24:40+08:00',\n",
       " '2018-01-05 14:24:57+08:00',\n",
       " '2018-01-05 14:59:36+08:00',\n",
       " '2018-01-05 21:03:28+08:00',\n",
       " '2018-01-08 10:56:49+08:00',\n",
       " '2018-01-08 10:56:50+08:00',\n",
       " '2018-01-08 10:57:27+08:00',\n",
       " '2018-01-09 14:56:01+08:00',\n",
       " '2018-01-10 14:42:49+08:00',\n",
       " '2018-01-11 23:15:51+08:00',\n",
       " '2018-01-12 09:47:41+08:00',\n",
       " '2018-01-12 10:01:18+08:00',\n",
       " '2018-01-12 11:09:57+08:00',\n",
       " '2018-01-12 11:10:08+08:00',\n",
       " '2018-01-12 14:13:20+08:00',\n",
       " '2018-01-12 14:13:34+08:00',\n",
       " '2018-01-12 14:13:34+08:00',\n",
       " '2018-01-18 09:54:28+08:00',\n",
       " '2018-01-18 09:58:33+08:00',\n",
       " '2018-01-18 10:30:18+08:00',\n",
       " '2018-01-18 13:50:18+08:00',\n",
       " '2018-01-18 13:53:15+08:00',\n",
       " '2018-01-19 09:01:40+08:00',\n",
       " '2018-01-19 09:01:42+08:00',\n",
       " '2018-01-19 14:22:44+08:00',\n",
       " '2018-01-19 14:22:46+08:00',\n",
       " '2018-01-19 14:26:05+08:00',\n",
       " '2018-01-19 14:26:21+08:00',\n",
       " '2018-01-19 14:28:34+08:00',\n",
       " '2018-01-19 14:29:32+08:00',\n",
       " '2018-01-22 09:27:33+08:00',\n",
       " '2018-01-22 09:33:52+08:00',\n",
       " '2018-01-22 13:35:46+08:00',\n",
       " '2018-01-22 13:35:46+08:00',\n",
       " '2018-01-22 13:36:35+08:00',\n",
       " '2018-01-22 13:46:20+08:00',\n",
       " '2018-01-22 13:47:24+08:00',\n",
       " '2018-01-22 13:53:23+08:00',\n",
       " '2018-01-22 22:47:01+08:00',\n",
       " '2018-01-23 10:41:25+08:00',\n",
       " '2018-01-23 10:41:51+08:00',\n",
       " '2018-01-23 10:42:33+08:00',\n",
       " '2018-01-23 10:44:17+08:00',\n",
       " '2018-01-23 10:44:20+08:00',\n",
       " '2018-01-23 10:58:43+08:00',\n",
       " '2018-01-23 10:58:43+08:00',\n",
       " '2018-01-23 11:01:44+08:00',\n",
       " '2018-01-23 11:02:05+08:00',\n",
       " '2018-01-23 11:02:19+08:00',\n",
       " '2018-01-23 11:20:34+08:00',\n",
       " '2018-01-23 11:24:06+08:00',\n",
       " '2018-01-23 11:24:26+08:00',\n",
       " '2018-01-23 14:38:34+08:00',\n",
       " '2018-01-23 14:38:34+08:00',\n",
       " '2018-01-23 14:39:39+08:00',\n",
       " '2018-01-23 14:39:39+08:00',\n",
       " '2018-01-23 14:50:33+08:00',\n",
       " '2018-01-23 14:53:00+08:00',\n",
       " '2018-01-23 14:53:00+08:00',\n",
       " '2018-01-23 14:55:12+08:00',\n",
       " '2018-01-23 14:55:12+08:00',\n",
       " '2018-01-23 14:56:38+08:00',\n",
       " '2018-01-23 14:56:38+08:00',\n",
       " '2018-01-23 14:58:58+08:00',\n",
       " '2018-01-23 21:09:07+08:00',\n",
       " '2018-01-23 21:13:43+08:00',\n",
       " '2018-01-23 21:15:55+08:00',\n",
       " '2018-01-23 21:23:28+08:00',\n",
       " '2018-01-23 21:24:18+08:00',\n",
       " '2018-01-23 21:25:38+08:00',\n",
       " '2018-01-23 22:50:30+08:00',\n",
       " '2018-01-23 23:20:06+08:00',\n",
       " '2018-01-24 09:02:38+08:00',\n",
       " '2018-01-24 09:16:34+08:00',\n",
       " '2018-01-24 09:22:28+08:00',\n",
       " '2018-01-24 09:22:28+08:00',\n",
       " '2018-01-24 09:55:06+08:00',\n",
       " '2018-01-24 09:55:06+08:00',\n",
       " '2018-01-24 10:48:56+08:00',\n",
       " '2018-01-24 10:48:56+08:00',\n",
       " '2018-01-24 14:57:06+08:00',\n",
       " '2018-01-24 14:57:55+08:00',\n",
       " '2018-01-25 10:41:19+08:00',\n",
       " '2018-01-25 14:14:05+08:00',\n",
       " '2018-01-25 14:14:05+08:00',\n",
       " '2018-01-25 14:22:31+08:00',\n",
       " '2018-01-25 14:22:31+08:00',\n",
       " '2018-02-05 10:10:10+08:00',\n",
       " '2018-02-09 09:20:46+08:00',\n",
       " '2018-02-09 22:44:15+08:00',\n",
       " '2018-02-09 22:44:16+08:00',\n",
       " '2018-02-09 22:45:19+08:00',\n",
       " '2018-02-09 22:48:00+08:00']"
      ]
     },
     "execution_count": 93,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "list(dates)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 94,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'C:\\\\Users\\\\新田草\\\\Desktop\\\\正仁量化\\\\简单K线图.html'"
      ]
     },
     "execution_count": 94,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import pyecharts.options as opts\n",
    "from pyecharts.charts import Candlestick\n",
    " \n",
    "# x_data = [\"2017-10-24\", \"2017-10-25\", \"2017-10-26\", \"2017-10-27\"]\n",
    "# y_data = [[20, 30, 10, 35], [40, 35, 30, 55], [33, 38, 33, 40], [40, 40, 32, 42]]\n",
    "\n",
    "x_data = list(dates)\n",
    "y_data = prices\n",
    "\n",
    "(\n",
    " Candlestick(init_opts=opts.InitOpts(width=\"1200px\", height=\"600px\"))\n",
    " .add_xaxis(xaxis_data=x_data)\n",
    " .add_yaxis(series_name=\"\", y_axis=y_data)\n",
    " .set_series_opts()\n",
    " .set_global_opts(\n",
    "  yaxis_opts=opts.AxisOpts(\n",
    "   splitline_opts=opts.SplitLineOpts(\n",
    "    is_show=True, linestyle_opts=opts.LineStyleOpts(width=1)\n",
    "   )\n",
    "  )\n",
    " )\n",
    " .render(\"简单K线图.html\")\n",
    ")\n",
    "\n",
    "# c = (\n",
    "#  Kline()\n",
    "#  .add_xaxis([\"2017/7/{}\".format(i + 1) for i in range(31)])\n",
    "#  .add_yaxis(\n",
    "#   \"kline\",\n",
    "#   data,\n",
    "#   itemstyle_opts=opts.ItemStyleOpts(\n",
    "#    color=\"#ec0000\",\n",
    "#    color0=\"#00da3c\",\n",
    "#    border_color=\"#8A0000\",\n",
    "#    border_color0=\"#008F28\",\n",
    "#   ),\n",
    "#  )\n",
    "#  .set_global_opts(\n",
    "#   xaxis_opts=opts.AxisOpts(is_scale=True),\n",
    "#   yaxis_opts=opts.AxisOpts(\n",
    "#    is_scale=True,\n",
    "#    splitarea_opts=opts.SplitAreaOpts(\n",
    "#     is_show=True, areastyle_opts=opts.AreaStyleOpts(opacity=1)\n",
    "#    ),\n",
    "#   ),\n",
    "#   datazoom_opts=[opts.DataZoomOpts(type_=\"inside\")],\n",
    "#   title_opts=opts.TitleOpts(title=\"Kline-ItemStyle\"),\n",
    "#  )\n",
    "#  .render(\"K线图鼠标缩放.html\")\n",
    "# )"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 95,
   "metadata": {},
   "outputs": [],
   "source": [
    "from pyecharts import options as opts\n",
    "from pyecharts.charts import Kline\n",
    " \n",
    "data = [\n",
    " [2320.26, 2320.26, 2287.3, 2362.94],\n",
    " [2300, 2291.3, 2288.26, 2308.38],\n",
    " [2295.35, 2346.5, 2295.35, 2345.92],\n",
    " [2347.22, 2358.98, 2337.35, 2363.8],\n",
    " [2360.75, 2382.48, 2347.89, 2383.76],\n",
    " [2383.43, 2385.42, 2371.23, 2391.82],\n",
    " [2377.41, 2419.02, 2369.57, 2421.15],\n",
    " [2425.92, 2428.15, 2417.58, 2440.38],\n",
    " [2411, 2433.13, 2403.3, 2437.42],\n",
    " [2432.68, 2334.48, 2427.7, 2441.73],\n",
    " [2430.69, 2418.53, 2394.22, 2433.89],\n",
    " [2416.62, 2432.4, 2414.4, 2443.03],\n",
    " [2441.91, 2421.56, 2418.43, 2444.8],\n",
    " [2420.26, 2382.91, 2373.53, 2427.07],\n",
    " [2383.49, 2397.18, 2370.61, 2397.94],\n",
    " [2378.82, 2325.95, 2309.17, 2378.82],\n",
    " [2322.94, 2314.16, 2308.76, 2330.88],\n",
    " [2320.62, 2325.82, 2315.01, 2338.78],\n",
    " [2313.74, 2293.34, 2289.89, 2340.71],\n",
    " [2297.77, 2313.22, 2292.03, 2324.63],\n",
    " [2322.32, 2365.59, 2308.92, 2366.16],\n",
    " [2364.54, 2359.51, 2330.86, 2369.65],\n",
    " [2332.08, 2273.4, 2259.25, 2333.54],\n",
    " [2274.81, 2326.31, 2270.1, 2328.14],\n",
    " [2333.61, 2347.18, 2321.6, 2351.44],\n",
    " [2340.44, 2324.29, 2304.27, 2352.02],\n",
    " [2326.42, 2318.61, 2314.59, 2333.67],\n",
    " [2314.68, 2310.59, 2296.58, 2320.96],\n",
    " [2309.16, 2286.6, 2264.83, 2333.29],\n",
    " [2282.17, 2263.97, 2253.25, 2286.33],\n",
    " [2255.77, 2270.28, 2253.31, 2276.22],\n",
    "]\n",
    " \n",
    " \n",
    "c = (\n",
    " Kline()\n",
    " .add_xaxis(xaxis_data=x_data)\n",
    " .add_yaxis(\n",
    "  \"CY1805\",\n",
    "  y_axis=y_data,\n",
    "  itemstyle_opts=opts.ItemStyleOpts(\n",
    "   color=\"#ec0000\",\n",
    "   color0=\"#00da3c\",\n",
    "   border_color=\"#8A0000\",\n",
    "   border_color0=\"#008F28\",\n",
    "  ),\n",
    " )\n",
    " .set_global_opts(\n",
    "  xaxis_opts=opts.AxisOpts(is_scale=True),\n",
    "  yaxis_opts=opts.AxisOpts(\n",
    "   is_scale=True,\n",
    "   splitarea_opts=opts.SplitAreaOpts(\n",
    "    is_show=True, areastyle_opts=opts.AreaStyleOpts(opacity=1)\n",
    "   ),\n",
    "  ),\n",
    "  datazoom_opts=[opts.DataZoomOpts(type_=\"inside\")],\n",
    "  title_opts=opts.TitleOpts(title=\"Kline-ItemStyle\"),\n",
    " )\n",
    " .render(\"K线图鼠标缩放.html\")\n",
    ")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.0"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
